package org.pupil.tolerant;

import org.pupil.common.constants.FaultTolerant;
import org.pupil.spi.ExtensionLoader;

import java.io.IOException;


/**
 * @Description: 容错策略工厂
 * @Author: pupil
 * @Date: 2024/07/17 下午 4:26
 */
public class FaultTolerantFactory {


    public static FaultTolerantStrategy get(FaultTolerant faultTolerant) {
        return ExtensionLoader.getInstance().get(faultTolerant.name());
    }
    public static FaultTolerantStrategy get(String name){
        return ExtensionLoader.getInstance().get(name);
    }


    public static void init() throws IOException, ClassNotFoundException {
        ExtensionLoader.getInstance().loadExtension(FaultTolerantStrategy.class);
    }
}
